package net.showcal.api.request.im;


import com.alibaba.fastjson.JSON;
import net.showcal.api.ApiRuleException;
import net.showcal.api.XiniuRequest;
import net.showcal.api.domain.im.MessageContent;
import net.showcal.api.internal.util.XiniuHashMap;
import net.showcal.api.response.im.SendIMMessageResponse;

import java.util.Map;


/**
 * <p/>
 * <p/>
 * <pre>
 * ***************************************************************
 *  Copyright (c) 2014 –瘦咖网络
 *  Title: com.showcal.im.helper.ImHelperImpl
 *  Description: im Request
 *  @since
 *  @author 顾志雄
 * ***************************************************************
 * </pre>
 */
public class SendIMMessageRequest implements XiniuRequest<SendIMMessageResponse> {
    private XiniuHashMap udfParams = new XiniuHashMap();

    /**
     * 获取API名称
     */
    @Override
    public String getApiMethodName() {
        return "im.questionForIM.send";
    }

    /**
     * 消息id
     */
    private Long messageId;
    /**
     * 会话 id
     */
    private String conversationId;
    /**
     * 用户id,发送者
     */
    private Long openId;
    /**
     * 服务的瘦咖ID
     */
    private Long showcalId;
    /**
     * 消息发送时间
     */
    private String createdAt;
    /**
     * 消息内通
     */
    private MessageContent content;
    /**
     * 自定义扩展字段
     */
    private Map<String, String> extension;
    /**
     * 消息tag
     */
    private Long tag;
    /**
     * 消息标签ID
     */
    private Long tagId;

    public Long getMessageId() {
        return messageId;
    }

    public void setMessageId(Long messageId) {
        this.messageId = messageId;
    }

    public String getConversationId() {
        return conversationId;
    }

    public void setConversationId(String conversationId) {
        this.conversationId = conversationId;
    }

    public Long getOpenId() {
        return openId;
    }

    public void setOpenId(Long openId) {
        this.openId = openId;
    }

    public Long getShowcalId() {
        return showcalId;
    }

    public void setShowcalId(Long showcalId) {
        this.showcalId = showcalId;
    }

    public String getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(String createdAt) {
        this.createdAt = createdAt;
    }

    public MessageContent getContent() {
        return content;
    }

    public void setContent(MessageContent content) {
        this.content = content;
    }

    public Map<String, String> getExtension() {
        return extension;
    }

    public void setExtension(Map<String, String> extension) {
        this.extension = extension;
    }

    public Long getTag() {
        return tag;
    }

    public void setTag(Long tag) {
        this.tag = tag;
    }

    public Long getTagId() {
        return tagId;
    }

    public void setTagId(Long tagId) {
        this.tagId = tagId;
    }

    @Override
    public Map<String, String> getTextParams() {
        XiniuHashMap txtParams = new XiniuHashMap();
        txtParams.put("messageId", this.messageId);
        txtParams.put("conversationId", this.conversationId);
        txtParams.put("openId", this.openId);
        txtParams.put("showcalId", this.showcalId);
        txtParams.put("createdAt", this.createdAt);
        if (this.content != null) {
            txtParams.put("content", JSON.toJSONString(this.content));
        }
        if (this.extension != null) {
            txtParams.put("extension", JSON.toJSONString(this.extension));
        }
        txtParams.put("tag", this.tag);
        txtParams.put("tagId", this.tagId);
        if (this.udfParams != null) {
            txtParams.putAll(this.udfParams);
        }
        return txtParams;
    }

    @Override
    public Long getTimestamp() {
        return null;
    }

    @Override
    public void setTimestamp(Long timestamp) {

    }

    @Override
    public Class getResponseClass() {
        return SendIMMessageResponse.class;
    }

    @Override
    public void check() throws ApiRuleException {
    }

    @Override
    public Map
            <String, String> getHeaderMap() {
        return null;
    }

    @Override
    public void putOtherTextParam(String key, String value) {
        this.udfParams.put(key, value);
    }
}